

if (typeof jQuery !== 'undefined') {
	(function($) {
		$('#spinner').ajaxStart(function() {
			$(this).fadeIn();
		}).ajaxStop(function() {
			$(this).fadeOut();
		});
	})(jQuery);
}


$(document).ready(function (){
	
	// TREE MENU
	
	$('#treeMenu ul li:has("div")').find('span:first').addClass('closed'); //adds a closed class to all span elements -> all spans are closed
	$('#treeMenu ul li:has("div")').find('div').hide();	
	$('#treeMenu li:has("div")').find('span:first').click (function (){ 
		$(this).parent('li').find('span:first').toggleClass('opened');
		$(this).parent('li').find('div:first').slideToggle();
	 
	 });
}); 


$(document).ready(function () {
jQuery("#treeMenu2")


	.jstree({

        "plugins" : ["ui", "html_data",   "cookies"]	
		         
	    })
	
	// 1) if using the UI plugin bind to select_node
	.bind("select_node.jstree", function (event, data) { 
		// `data.rslt.obj` is the jquery extended node that was clicked
//		alert(data.rslt.obj.attr("id"));
		//http://stackoverflow.com/questions/4597689/jstree-make-node-expand-when-single-clicked-instead-of-double-click
		$("#treeMenu2").jstree("toggle_node", data.rslt.obj);
		$("#treeMenu2").jstree("deselect_node", data.rslt.obj);
		var href= data.rslt.obj.children("a").attr("href");
		document.location.href = href;
	})
	.delegate("a", "click", function (event, data) { 
		// alert( event.isDefaultPrevented() );
		//event.preventDefault(); 
		 return true;
		
	})
	

	
	// 2) if not using the UI plugin - the Anchor tags work as expected
	//    so if the anchor has a HREF attirbute - the page will be changed
	//    you can actually prevent the default, etc (normal jquery usage)
//	.delegate("a", "click", function (event, data) { event.preventDefault(); })

});






